<template>
    <div id="wrapper" ref="scroll_content">
        <div id="content">
            <slot></slot>
        </div>
    </div>
</template>

<script>
    import BScroll from 'better-scroll'
    export default {
        name: "Scroll",
        data(){
          return{
              scroll:null
          }
        },
        props:{
            probeType: Number,
            pullUpLoad: Boolean
        },
        mounted() {
            this.scroll = new BScroll(this.$refs.scroll_content,{
                probeType:this.probeType,
                click:true,
                pullUpLoad:this.pullUpLoad
            });
            //监听滚动事件
            this.scroll.on('scroll',position => {
                // console.log(position);
                this.$emit('scroll',position)
            });
            //监听上拉加载事件
            this.scroll.on('pullingUp',() => {
                this.$emit('pullingUp')
            })
        },
        methods:{
            scrollTo(x,y,time){
                this.scroll.scrollTo(x,y,time)
            },
            finishPullUp(){
                this.scroll.finishPullUp()
            }
        }
    }
</script>

<style scoped>
</style>